package com.testingedu.action.background;

import com.testingedu.jdbcDao.TUserDao;
import com.testingedu.model.TUser;

public class TStudentAction extends RequestContext{
	private static final long serialVersionUID = -3312281794910768326L;
	private TUser tUser;
	private static TUserDao tUserDao = new TUserDao();
	public TUser gettUser() {
		return tUser;
	}
	public void settUser(TUser tUser) {
		this.tUser = tUser;
	}
	
	public void _list() throws Exception {
		String url = request.getParameter("url");
		if ("info".equals(url)) {
			this.info(url);
		} else {
			createQueryResult();
			String userName = request.getParameter("name");
			tUserDao.list(queryResult,userName, "学员");
			request.setAttribute("queryResult", queryResult);
			request.getRequestDispatcher("/WEB-INF/admin/jsp/student/list.jsp")
					.forward(request, response);
		}
	}
	
	private void info(String url) throws Exception {
		int userId = Integer.parseInt(request.getParameter("id"));
		tUser = tUserDao.info(userId);
		request.setAttribute("tUser", tUser);
		request.getRequestDispatcher("/WEB-INF/admin/jsp/student/info.jsp")
				.forward(request, response);
	}
}
